package it.polimi.entities;

import it.polimi.entitiesDTO.PacketFlightDTO;

import java.io.Serializable;

import javax.persistence.*;

import java.util.List;


/**
 * The persistent class for the packet_flight database table.
 * 
 */
@Entity
@Table(name="packet_flight")


@NamedQueries ({ @NamedQuery(name="PacketFlight.FIND_ALL", query="SELECT p FROM PacketFlight p"),
	 			 @NamedQuery(name=PacketFlight.FIND_PACKETFLIGHT, query="SELECT p FROM PacketFlight p WHERE p.id = :id")
})
public class PacketFlight implements Serializable {
	private static final long serialVersionUID = 1L;
	
	public static final String FIND_ALL = "Packet.findAll";
	
	public static final String FIND_PACKETFLIGHT = "Packet.findPacketFlight";

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	//bi-directional many-to-one association to Packet
	@ManyToOne
	@JoinColumn(name="packet")
	private Packet packet;

	//bi-directional many-to-one association to PacketFlight
	@ManyToOne
	@JoinColumn(name="flight")
	private Flight flight;

	//bi-directional many-to-one association to PersonalizedPacket
	@ManyToOne
	@JoinColumn(name="personalizedPacket")
	private PersonalizedPacket personalizedPacket;

	public PacketFlight() {
		super();
	}
	
	public PacketFlight(Packet packet) {
		this.packet = packet;
		packet.addPacketFlight(this);
	}
	
	public PacketFlight(PacketFlightDTO packetFlight, Packet packet, Flight flight) {
		this.id = packetFlight.getId();
		this.packet = packet;
		this.flight = flight;
	}
	
	public PacketFlight(Packet packet, Flight flight) {
		this.packet = packet;
		this.flight = flight;
	}
	
	public PacketFlight(PersonalizedPacket packet, Flight flight) {
		this.personalizedPacket = packet;
		this.flight = flight;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	public Packet getPacket() {
		return packet;
	}

	public void setPacket(Packet packet) {
		this.packet = packet;
	}

	public Flight getFlight() {
		return flight;
	}

	public void setFlight(Flight flight) {
		this.flight = flight;
	}

	public PersonalizedPacket getPersonalizedPacket() {
		return this.personalizedPacket;
	}

	public void setPersonalizedPacket(PersonalizedPacket personalizedPacket) {
		this.personalizedPacket = personalizedPacket;
	}

}